<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="javax.naming.InitialContext"%>
<%@page import="org.crud4j.core.CrudService"%>
<%@page import="org.crud4j.portlet.CrudContextKey"%>
<%@page import="org.crud4j.core.CrudField"%>
<fmt:setBundle basename="labels"/>
<c:if test="${not empty emptyBean.browseFilterFields}">
	<table cellpadding="5px" cellspacing="0" class="crud">
		<c:forEach var="field" items="${emptyBean.browseFilterFields}">
			<form action="<portlet:actionURL />"><input type="hidden"
				name="action" value="FILTERED_BROWSE" />
			<tr>
				<td><label for="<c:out value="${field.def.name}"/>"><c:out
					value="${field.def.label}" /></label></td>
				<c:if test="${field.def.crudBean}">
				<td>
					<% 
				CrudService crudService = (CrudService) request.getAttribute(CrudContextKey.CRUD_SERVICE.getKey()); 
				CrudField field = (CrudField) pageContext.getAttribute("field") ;
				pageContext.setAttribute("fks", crudService.findAll(field.getDef().getType()).getBeans()) ;
				%>
					<select name="<c:out value="${field.def.name}"/>">
						<c:forEach var="fk" items="${fks}">
							<option value="<c:out value="${fk.id}"/>"><c:out
								value="${fk.label}" /></option>
						</c:forEach>
					</select>
				<td>
				</c:if>
				<c:if test="${!field.def.crudBean}">
					<td><input type="text" name="<c:out value="${field.def.name}"/>"
						class="crud" /></td>
				</c:if>
				<td>
					<input type="submit" value="<fmt:message key="label.filter"/>" class="crud">
				</td>
			</tr>
			</form>
		</c:forEach>
	</table>
</c:if>
